# -*- encoding: utf-8 -*-

import math


def get_enum_name_by_value(enum_class, value):
    """
    由枚举值值取对应的枚举类型
    :param enum_class: class, 枚举类
    :param value: int, 枚举值
    :return: str, 枚举类型
    """
    enum_members = enum_class.__members__
    for enum_constant_name, enum_constant in enum_members.items():
        if enum_constant.value == value:
            return enum_constant_name


def get_value_by_enum_name(enum_class, name):
    """
    由枚举值值取对应的枚举类型
    :param enum_class: class, 枚举类
    :param name: str, 枚举值
    :return: int, 枚举类型
    """
    enum_members = enum_class.__members__
    for enum_constant_name, enum_constant in enum_members.items():
        if enum_constant_name == name:
            return enum_constant



